<?php
// +----------------------------------------------------------------------
// | Author: 黄泽宏 <2623213969@qq.com>
// +----------------------------------------------------------------------

namespace app\home\controller;
/**
 * 会员返佣控制器
 */
class MemberController extends HomeController {
    public function _initialize() {
        parent::_initialize();
    }

    /**
     * 会员返佣首页面
     */
    public function index(){
        $code = "http://".$_SERVER['SERVER_NAME'].U('member_qrcode',array('user_id'=>$this->user_id));
        $this->assign('code',$code);
        return $this->fetch('index');
    }
    
   /**
     * 会员返佣说明页面
     */
    public function member_help(){
        return $this->fetch('member_help');
    }
    
  /**
    * 会员返佣下线会员页面
    */
    public function member_offline(){
        if($this->user_id){
            $user_list = M("user")->where(array("distributor_id"=>$this->user_id))->select();
            $this->assign("user_list",$user_list);
            return $this->fetch('member_offline');
        }
        
    }
    
  /**
    * 会员返佣明细页面
    */
    public function member_detail(){
        return $this->fetch('member_detail');
    }
     
   /**
    * 获取二维码的信息页面
    */
    public function member_qrcode(){
        $user_id = input('user_id',0);
        if($user_id!=$this->user_id){
           $member_data['distributor_id'] = $user_id;
           db('user')->where(array("id"=>$this->user_id))->update($member_data);
        }
        header('Location:'.Url('Index/index'));
    }
    

}